function [action,alg]=action_selector(alg)

global EXP_RATE

i1=alg.prodcount+1;



if alg.Pi(i1,1)>=alg.Pi(i1,2)
    greedy_action=1;
else
    greedy_action=2;
end

if greedy_action==1
    non_greedy_action=2;
else
    non_greedy_action=1;
end


number=rand(1);

if number<EXP_RATE 
    action=non_greedy_action;
    alg.flag=2;
else 
    action=greedy_action;
    alg.flag=1;
end

%EXP_RATE=0.5*log(alg.iter+1)/(alg.iter+1000);
%if mod(alg.iter,1000)==0
    %EXP_RATE=EXP_RATE*0.9999;
%end